import Vue from 'vue'
import SvgIcon from '@/components/SvgIcon'// svg component

// register globally
Vue.component('svg-icon', SvgIcon)

const req = require.context('./svg', false, /\.svg$/)
const requireAll = requireContext => requireContext.keys().map(requireContext)
requireAll(req)

/* eslint-disable */
// 定义iconfont库
const iconfontVersion = ['567566_pwc3oottzol', '1066523_6bvkeuqao36']
const iconfontUrlCss = `//at.alicdn.com/t/font_$key.css`

// 定义动态插入方法
const loadStyle = url => {
  const link = document.createElement('link')
  link.type = 'text/css'
  link.rel = 'stylesheet'
  link.href = url
  const head = document.getElementsByTagName('head')[0]
  head.appendChild(link)
}

// 动态插入
iconfontVersion.forEach(ele => {
  loadStyle(iconfontUrlCss.replace('$key', ele))
})
